package com.zhiwei.msf.infra.oauth.constants;

import lombok.Data;

/**
 * function 响应体
 * author zhiwei.yang
 * time 2020-2-25-15:15
 */
@Data
public final class ResponseMsg {

    private ResponseMsg(){}

    /** 状态码 **/
    private String code;

    /** 状态码说明 **/
    private String msg;

    /** 业务数据 **/
    private Object data;

    public static ResponseMsg buildFailResponseMsg(Object data){
        return buildResponseMsg("000001","failure", data);
    }

    public static ResponseMsg buildSuccessResponseMsg(Object data){
        return buildResponseMsg("000000","success", data);
    }

    /**
     * 构建相应体结构
     * @param code
     * @param msg
     * @param data
     * @return
     */
    public static ResponseMsg buildResponseMsg(String code, String msg, Object data){
        ResponseMsg responseMsg = new ResponseMsg();
        responseMsg.setCode(code);
        responseMsg.setMsg(msg);
        responseMsg.setData(data);
        return responseMsg;
    }

}